home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
ov_all.zip
/
TI637.ASC
< prev
next >
Wrap
Text File
|
1991-11-25
|
9KB
|
265 lines
PRODUCT : ObjectVision NUMBER : 637
VERSION : 1.0
OS : WIN
DATE : November 25, 1991 PAGE : 1/4
TITLE : Flexible Selection Lists
Flexible Selection Lists:
Selection lists are a field type which allow the user to choose
from a predefined group of choices. The user is not permitted to
type in a new entry while completing the form. Instead, one of
the available choices in the list must be selected. Many times
users want to be able to add to the list dynamically as they fill
out a form. If the field is connected to the index field of a
database there is a technique to allow adding new fields.
One field on the form would be used to look up from the database
and would consequently be connected for reading from the database
(and displaying the choices in a list). The other field would be
connected for writing to the database. An additional button
which uses the Insert function will prevent users from
accidentally replacing an existing name with a new name. Lastly
with a few extra steps the form can be made to prompt for the new
name when appropriate.
This example builds a simple database with two fields to
illustrate the concept of a flexible selection list. The
database will hold names and phone numbers. The names will be
listed on the form so that the user may select from the list a
name and the matching phone number will appear automatically.
When a new name needs to be added to the list the form will allow
the user to type into a separate field and insert the name to
the database so that it will be placed in the list.
1. Create a form with two fields. Call one Names and the other
Phone Numbers.
2. Create a database to store the names and numbers next. Use
Tools | Links | Create, select Paradox. When the dialog box
appears enter Lookup for the Link Name, FlexSel for the
table name and press TAB. ObjectVision will prompt you with
an error message "Unable to open Paradox table. Create a
new table named FLEXSEL?". Choose "OK" to let ObjectVision
create a new table for you. Let ObjectVision create the
buttons for you as you return to the form. DBase users may
select DBase when creating the database, but will need to
type in the index name, Flexsel, as well.
PRODUCT : ObjectVision NUMBER : 637
VERSION : 1.0
OS : WIN
DATE : November 25, 1991 PAGE : 2/4
TITLE : Flexible Selection Lists
3. Enter some data into the database to begin the selection
list. Close the form tool (Form | Close Tool) and begin
entering names and numbers. After typing in the name and
number be sure and press the Enter button on the form, then
press the Clear button on the form before adding the next
name and number. You only need to add three or four names
before proceeding to the next step. Enter Add Another Name,
with no phone number, as one of the entries into the
database.
4. Now that you have the form started, and a link to an indexed
database format the selection list field Choose Tools |
Form. Highlight the Names field and choose Properties |
Field Type | Selection List. Notice the automatic box is
checked by default, the names entered earlier should fill in
the dialog box below. Choose OK.
5. Two additional fields are necessary to complete the form:
Create a new field and call it New Name. Place this field
to the right of the Names field. Now create a second field
called Name Picked and place it below the Phone Numbers
field.
7. With the Name Picked field selected choose Tools | Tree.
Place a conclusion on the field of +Names (Objects |
Conclusion , +Names). Then close the tree tool ( Tree |
Close Tool).
8. Cut the Name Picked field off of the form (Edit | Cut).
This field will hold the selected value in the background on
a scratchpad form. Later the New Name field will check the
Name Picked field to find out which name was chosen. This
will determine whether it is necessary to prompt for a new
entry to the list.
Branching on the Name Picked field (rather than on the Names
field) prevents the decision tree from overriding the
database for automatically providing the selection list
values. There are two ways to create an automatic selection
list, a decision tree or a database. When a field is both
the branch node for a decision tree and connected to an
indexed field in a database the decision tree's values will
supersede the database values for the selection list.
PRODUCT : ObjectVision NUMBER : 637
VERSION : 1.0
OS : WIN
DATE : November 25, 1991 PAGE : 3/4
TITLE : Flexible Selection Lists
Checking on the dummy field Name Picked allows the Names
list to continue getting values from the database.
9. Now modify the link to read to a different field than it
writes from. Use Tools | Links to alter the connections
between the form and the database. Choose Modify on the
Lookup link. Highlight the Names field and press Connect.
Choose OK to leave the Names field in the database connected
to read to the Names field on the form. A second dialog box
will appear to prompt for the write field. Choose the New
Name field from the list and press OK. Press OK until the
form is back on the screen.
10. Create a third field (which will be formatted as a button in
a moment). Call the new field Add New Name and place the
field down at the bottom of the form under the Enter button.
Use Properties | Field Type | Button to set this field as a
button.
11. This button needs a decision tree conclusion of
@Insert("Lookup"). Use Tree | Tool, then Objects |
Conclusion to create the decision tree. Be sure to use the
same linkname that was used earlier, Lookup, and enclose it
in double quotes.
Note The last step is to build a decision tree on the New Name
field to indicate when to enter a new name to the list. The
decision tree needs a particular condition to indicate that
the new record is necessary,. The "dummy" record in the
database, Add Another Name, will be the indicator. If the
dummy record is selected the decision tree will cause the
New Name field to be prompted. If any other name is
selected, the New Name field will be skipped.
12. In the tree tool (Tools | Tree) select the New Name field
(Tree | Select | New Name) and choose Objects | Branch.
Branch on the field called Name Picked. Select Objects |
Conclusion and when prompted for the Condition of the
Conclusion type Add Another Name, after pressing the Return
(or Enter) key on the keyboard a dialog box will appear
requesting the Conclusion. Type +New Name. Choose Objects
| Conclusion a second time and type Otherwise as the
PRODUCT : ObjectVision NUMBER : 637
VERSION : 1.0
OS : WIN
DATE : November 25, 1991 PAGE : 4/4
TITLE : Flexible Selection Lists
condition and +Names as the Conclusion. Your application is
complete.
If the desired name is in the list, select it and the
accompanying phone number will appear. If the name desired
is not in the list and needs to be added, select from the
list Add Another Name, the cursor should pause at the New
Name field before proceeding. Because Add Another Name is
one of the records in the database (complete with a blank
phone number), the user must use the TAB key or mouse to
advance to the phone number field. This field is assumed
complete by ObjectVision since a blank value was delivered
back from the database. After typing both the name and the
number the user should press the Add New Name button to
write the new entry to the database. At this time the new
entry will be available in the selection list.
The basic idea here is that a selection list is a field which is
initially read-only. By assigning a different field on the form
for writing than for reading, additional entries can be made.
The purpose of adding a button with the Insert function on it is
to prevent accidentally replacing an existing record with the new
record. A dummy record in the database is used to trigger the
form to pause on a field which would otherwise be skipped.